package com.zhz.common.shiro.entity;

import com.google.common.collect.Sets;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.crazycake.shiro.AuthCachePrincipal;

import java.io.Serializable;
import java.util.Set;

/**
 * 用户登录成功之后，获取用户信息返回的数据
 *
 * @author zhouhengzhe
 * @date 2023/5/22
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class UserProfileResponse implements Serializable, AuthCachePrincipal {
    @ApiModelProperty("用户id")
    private String userId;
    @ApiModelProperty("手机号")
    private String mobile;
    @ApiModelProperty("用户名")
    private String username;
    @ApiModelProperty("公司名称")
    private String company;
    @ApiModelProperty("公司id")
    private String companyId;
    @ApiModelProperty("角色权限信息")
    @Builder.Default
    private RoleInfo roles = new RoleInfo();

    @Override
    public String getAuthCacheKey() {
        return null;
    }

    @Data
    @AllArgsConstructor
    @NoArgsConstructor
    @Builder
    public static class RoleInfo implements Serializable{
        @ApiModelProperty("权限菜单集合")
        @Builder.Default
        private Set<String> menus = Sets.newHashSet();

        @ApiModelProperty("权限点集合")
        @Builder.Default
        private Set<String> points = Sets.newHashSet();

        @ApiModelProperty("api权限集合")
        @Builder.Default
        private Set<String> apis = Sets.newHashSet();
    }
}
